#include "stdafx.h"
#include "RasterizerManager.h"
#include "GraphicsManager.h"

RasterizerManager::RasterizerManager(void)
{
	GraphicsManager* pGraphics = GraphicsManager::GetInstance();

	ID3D11Device* pDevice = pGraphics->getDevice();

	D3D11_RASTERIZER_DESC cullNone_desc;
	ZeroMemory(&cullNone_desc, sizeof(D3D11_RASTERIZER_DESC));

	cullNone_desc.CullMode = D3D11_CULL_NONE;
	cullNone_desc.FillMode = D3D11_FILL_SOLID;
	
	HRESULT hr = pDevice->CreateRasterizerState(&cullNone_desc, &states.CullNone);

	D3D11_RASTERIZER_DESC cullCC_desc;
	ZeroMemory(&cullCC_desc, sizeof(D3D11_RASTERIZER_DESC));

	cullCC_desc.CullMode = D3D11_CULL_BACK;
	cullCC_desc.FrontCounterClockwise = true; 
	cullCC_desc.FillMode = D3D11_FILL_SOLID;

	hr = pDevice->CreateRasterizerState(&cullCC_desc, &states.CullCounterClockwise);

	D3D11_RASTERIZER_DESC cullClockwise_desc;
	ZeroMemory(&cullClockwise_desc, sizeof(D3D11_RASTERIZER_DESC));

	cullClockwise_desc.CullMode = D3D11_CULL_FRONT;
	cullClockwise_desc.FrontCounterClockwise = true;
	cullClockwise_desc.FillMode = D3D11_FILL_SOLID;

	hr = pDevice->CreateRasterizerState(&cullClockwise_desc, &states.CullClockwise);
}

RasterizerManager::~RasterizerManager(void)
{
	states.CullClockwise->Release();
	states.CullCounterClockwise->Release();
	states.CullNone->Release();
}
